$(function() {
	// createKingEdtior();
	function getTableSource() {
		var tableSource = new $.jqx.dataAdapter({
			dataType : "json",
			dataFields : [ {
				name : "id",
				type : "int"
			}, {
				name : "uuid",
				type : "string"
			}, {
				name : "type",
				type : "int"
			}, {
				name : "title",
				type : "string"
			}, {
				name : "text",
				type : "string"
			}, {
				name : "creator",
				type : "string"
			} ],
			id : "id",
			url : "footer/getFooterInfoList.do"
		});
		return tableSource;
	}

	$("#dataTable").jqxDataTable(
			{
				width : "100%",
				source : getTableSource(),
				pageable : true,
				serverProcessing : true,
				pageSize : 18,
				pagerButtonsCount : 10,
				columnsResize : true,
				sortable : true,
				columns : [
						{
							text : "序号",
							cellsRenderer : function(row) {
								return (row + 1).toString();
							}
						},
						{
							text : "文章分类",
							dataField : "type",
							cellsRenderer : function(row, column, value,
									rowData) {
								return [ "", "网站说明", "返回/退换货", "常见问题", "售后政策",
										"联系客服", "招商合作", "隐私政策", "新手指南",
										"卖家开店流程" ][value];
							}
						}, {
							text : "文章标题",
							dataField : "title"
						}, {
							text : "内容",
							dataField : "text"
						}, {
							text : "添加人",
							dataField : "creator"
						} ],
			});
	$("#dataTable").on("rowDoubleClick", function(info, args) {
		if (args && args.flag) {
			info = args;
		}
//		
//		editingIndex = info.args.index;
//		editingData = info.args.row;
//		
		var href = window.location.href;
		var url = href.substring(0, href.lastIndexOf('/') + 1);
		var addr = url + 'footer/footerTemp.do?id=' + info.args.row.id
		window.location.href = addr;
		

		/*_editerIndex = layer.open({
			id : "sellerEditer",
			title : "查看/修改文章",
			type : 2,
			skin : 'layui-layer-rim',
			area : [ '1000px', '640px' ],
			content : url + 'footer/footerTemp.do?id=' + editingData.id
		});
		createKingEdtior();
		*/
	});
	$("#add").click(function() {
		var href = window.location.href;
		var url = href.substring(0, href.lastIndexOf('/') + 1);
		window.location.href = url + "footerEdit.do";
	});
});

/**
 * 是否选中一项
 * 
 * @returns
 */
function isSelected() {
	var rows = $("#dataTable").jqxDataTable("getSelection");
	if (rows.length < 1) {
		layer.msg("请选择一行数据", {
			shift : 6,
			offset : "5%"
		});
		return null;
	}
	return rows;
}
